{% extends "bootstrap/base.html" %}

{% block title %} Blog {% endblock%}

{% block head %}
{{ super() }}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="{{ url_for('static', filename = 'favicon.ico') }}" 
    type="image/x-icon"> 
<link rel="icon" href="{{ url_for('static', filename = 'favicon.ico') }}" 
    type="image/x-icon">
<link rel="stylesheet" href="{{ url_for('static',filename='css/common.css') }}"/>

<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?ac11a6f76a210ffe6692f475231e105f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
{% endblock %}

{% block navbar %}
<div class="navbar navbar-default">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="{{ url_for('main.index') }}">Pelucky's Blog</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">        
        <li {% if request.path == url_for('main.index') %}class="active"{% endif %}><a href="{{ url_for('main.index') }}">Home <span class="sr-only">(current)</span></a></li>
        <li {% if request.path == url_for('main.archive') %}class="active"{% endif %}><a href="{{ url_for('main.archive') }}">Archive</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right"> 
        <form class="navbar-form navbar-right" action='/search'>
          <div class="form-group">
            <input type="text" class="form-control" placeholder="Search" name="query">
          </div>
          <button type="submit" class="btn btn-default">Submit</button>
        </form>   
        {% if current_user.is_authenticated%}
        <li><img src="{{ current_user.gravatar(size=35) }}" class='img-circle gravatar' ></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin <span class="caret"></span></a>
          <ul class="dropdown-menu">
             <li><a href="{{ url_for('admin.index') }}"><span class="glyphicon glyphicon-dashboard"> Dashboard</a></li>
              <li><a href="{{ url_for('admin.write_article') }}"><span class="glyphicon glyphicon-plus"> Add Articles</a></li>
            <li><a href="{{ url_for('admin.change_user_info') }}"><span class="glyphicon glyphicon-user"> Change UserInfo</a></li>
            <li><a href="{{ url_for('admin.change_password') }}"><span class="glyphicon glyphicon-cog"> Change Password</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="{{ url_for('admin.logout') }}"><span class="glyphicon glyphicon-off"></span> Logout</a></li>
          </ul>
        </li>
        {% endif %}
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</div>
{% endblock %}

{%- block content %}
<div class="container">
  {% with messages = get_flashed_messages(with_categories=true) %}
    {% if messages %}
      {% for category, message in messages %}
        {% if category == 'success' %}
          <div class="alert alert-success">
        {% elif category == 'error' %}
          <div class="alert alert-danger">
        {% else %}
        <div class="alert alert-warning">
        {% endif %}
            <button type='button' class='close' data-dismiss='alert'>&times;</button>
            {{ message }}
          </div>
      {% endfor %}
      </ul>
    {% endif %}
  {% endwith %}
  {% block page_common_content %}{% endblock %}
</div>

<footer class="footer">
    <div class="container">
        <div class="row footer-top">
            <div class="col-sm-6 col-lg-6">
                <h4>Pelucky's Blog</h4>
                <p>Except where otherwise noted, content on this site is licensed under a 
                  <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
                  Creative Commons Attribution-ShareAlike 4.0 International License</a>.</p>
            </div>
            <div class="col-sm-6  col-lg-5 col-lg-offset-1">
                <div class="row about">
                    <div class="col-xs-3">
                        <h4>About</h4>
                        <ul class="list-unstyled">
                            <li><a href="{{ url_for('main.about_me') }}">Author</a></li>
                        </ul>
                    </div>
                    <div class="col-xs-3">
                        <h4>Contact</h4>
                        <ul class="list-unstyled">
                            <li><a href="//github.com/pelucky">Github</a></li>
                            <li><a href="mailto:pel@cpelucky.com">Email</a></li>
                        </ul>
                    </div>
                    <div class="col-xs-3">
                        <h4>RSS</h4>
                        <ul class="list-unstyled">
                            <li><a href="{{ url_for('main.rss') }}" target="_blank">XML feed</a></li>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-3">
                        <h4>Support</h4>
                        <ul class="list-unstyled">
                           <li><a href="//flask.pocoo.org/docs/0.12/" target="_blank">Flask</a></li>
                            <li><a href="//getbootstrap.com/" target="_blank">Bootstrap</a></li>
                            <li><a href="https://pandao.github.io/editor.md/" target="_blank">Editor.md</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <hr>
        <div class="row footer-bottom">
            <ul class="list-inline text-center">
                <li>Handmade by pelucky, Thanks to <a href="https://www.cdxy.me/">cdxy</a>.</li>
            </ul>
        </div>
    </div>
</footer>
{%- endblock content %}